package com.infore.dataAudit.service.audit;

import java.util.List;
import java.util.Map;

import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.delegate.Expression;

import com.infore.dataAudit.entity.TDataAudit;
import com.infore.dataAudit.service.audit.impl.DataAuditServiceImpl;
import com.infore.dataAudit.util.SpringUtil;

public class TimerTwoAudiListener implements ExecutionListener {
    
    /***
     * 属性注入 
     **/
    
    //审批用户id
    private Expression  assignee;
    
    /**
     * 
     */
    private static final long serialVersionUID = 1211221L;

    @Override
    public void notify(DelegateExecution execution) throws Exception {
        Map<String, Object> params = execution.getVariables();
        params.put("flowId", execution.getProcessInstanceId());
        params.put("assignee", assignee.getValue(execution));
        System.out.println(assignee.getValue(execution) +" ===审批用户id-------------------");
        System.out.println(params.get("stationMn") +" ---------");
        System.out.println("自动审核任务开始执行eventName: " +execution.getEventName());
        System.out.println("自动审核任务开始执行ActivityName: " +execution.getCurrentActivityName());
        //开启自动审核
        System.out.println("二级人工审核自动完成定时: ====================" );
        IDataAuditService dataAuditService = (DataAuditServiceImpl) SpringUtil.getBean("dataAuditService");
        List<TDataAudit> list = dataAuditService.autoCompleteTwoAudit(params);
        System.out.println("二级人工审核自动完成数量: ====================" + list.size());
    }
    
    

    

}
